#include <stdlib.h>

void swap(int v[], int i, int j)
{
    int temp;
    temp = v[i];
    v[i] = v[j];
    v[j] = temp;
}

void sort_numbers(int dest[], int num)
{
    int i, last;
    if (num < 1)
        return;
    swap(dest, 0, rand() % num);
    last = 0;
    for (i = 1; i < num; i++)
        if (dest[i] < dest[0])
            swap(dest, ++last, i);
    swap(dest, 0, last);
    sort_numbers(dest, last);
    sort_numbers(dest+last+1, num-last-1);
}
